from apps.project.models import ProjectQuotaModel, ProjectMaintainModel, ProjectDevelopModel


class ProjectQuotaService:
    def __init__(self, request) -> None:
        self.request = request
        super().__init__()


    # def quotaUsedBy(self, instance):
    #     """
    #     该方法用于判断报价单实例是否在维护、开发项目中被使用，如果被使用则返回True
    #     """
    #     isMaintainExist = ProjectQuotaModel.quota_maintain_relations.exists()
    #     isDevelopExist = ProjectQuotaModel.quota_develop_relations.exists()
    #
    #     if isMaintainExist or isDevelopExist:
    #         return True
    #     else:
    #         return False

    def quotaUsedBy(self, instance):
        """
        该方法用于判断报价单实例是否在维护、开发项目中被使用，如果被使用则返回True
        """
        isMaintainExist = ProjectMaintainModel.objects.filter(quoteFK=instance).exists()
        isDevelopExist = ProjectDevelopModel.objects.filter(quoteFK=instance).exists()

        if isMaintainExist or isDevelopExist:
            return True
        else:
            return False

